package scantask.containers;

import gov.nasa.worldwind.layers.AirspaceLayer;

import java.util.Map;

import scantask.client.threeDObjects.ComponentPolygone;
import scantask.client.threeDObjects.PolygonePool;
import scantask.client.threeDObjects.exceptions.PolygoneCreationException;
import scantask.containers.exceptions.MissingLayerException;
import scantask.containers.exceptions.UnInitializeObjectException;

public abstract class InformationObject {
	
	protected Coordinate _coordinate;
	protected ZoomLevel _viewInterval;
	
	protected ComponentPolygone _polygone;
	
	public InformationObject(Coordinate coordinate, ZoomLevel viewInterval) throws UnInitializeObjectException {
		if (coordinate == null) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Failed construct new InformationObject Coordinate is null");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("Failed construct new InformationObject Coordinate is null");
			throw new UnInitializeObjectException();
		}
		
		this._coordinate = coordinate;
		this._viewInterval = viewInterval;
		
	}
	
	public InformationObject(Coordinate coordinate, ZoomLevel viewInterval, PolygonePool pool) throws UnInitializeObjectException {
		if (coordinate == null) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Failed construct new InformationObject Coordinate is null");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("Failed construct new InformationObject Coordinate is null");
			throw new UnInitializeObjectException();
		}
		
		this._coordinate = coordinate;
		this._viewInterval = viewInterval;
	}
	
	public Coordinate getCoordinate() {
		return this._coordinate;
	}
	
	public ZoomLevel getViewInterval() throws UnInitializeObjectException {
		if (this._viewInterval == null) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("viewInterval is null");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("viewInterval is null");
			throw new UnInitializeObjectException();
		}
		
		return this._viewInterval;
	}
	
	public void setCoordinate(Coordinate coordinate) throws UnInitializeObjectException {
		if (coordinate == null) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Failed set InformationObject Coordinate is null");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("Failed set InformationObject Coordinate is null");
			throw new UnInitializeObjectException();
		}
		
		this._coordinate = coordinate;
	}
	
	public void setViewInterval(ZoomLevel viewInterval) {
		this._viewInterval = viewInterval;
	}
	
	
	public abstract String getType();
	
	public abstract String getCleanType();
	
	public abstract void buildDisplayedObject(PolygonePool polygonePool) throws PolygoneCreationException;
	
	public ComponentPolygone getPolygone() throws UnInitializeObjectException {
		if (this._polygone == null) {
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("Failed you must build the polygone first");
			throw new UnInitializeObjectException();
		}
		
		return this._polygone;
		
	}
	
	public abstract void init3DObject(Map<String, AirspaceLayer> layers) throws MissingLayerException;
	
	public abstract String getToolTipDescription();

}
